var t = require("../../@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", { value: !0 }),
  (exports.default = void 0);
var s = t(require("../lib/proj4")),
  i = {
    PI: 3.141592653589793,
    x_pi: 52.35987755982988,
    delta: function (t, s) {
      var i = 6378245,
        a = 0.006693421622965943,
        n = this.transformLat(s - 105, t - 35),
        h = this.transformLon(s - 105, t - 35),
        r = (t / 180) * this.PI,
        e = Math.sin(r);
      e = 1 - a * e * e;
      var o = Math.sqrt(e);
      return {
        lat: (n = (180 * n) / (((i * (1 - a)) / (e * o)) * this.PI)),
        lon: (h = (180 * h) / ((i / o) * Math.cos(r) * this.PI)),
      };
    },
    gcj_decrypt: function (t, s) {
      if (this.outOfChina(t, s)) return { lat: t, lon: s };
      var i = this.delta(t, s);
      return { lat: t - i.lat, lon: s - i.lon };
    },
    distance: function (t, s, i, a) {
      var n =
        Math.cos((t * this.PI) / 180) *
          Math.cos((i * this.PI) / 180) *
          Math.cos(((s - a) * this.PI) / 180) +
        Math.sin((t * this.PI) / 180) * Math.sin((i * this.PI) / 180);
      n > 1 && (n = 1), n < -1 && (n = -1);
      var h = 6371e3 * Math.acos(n);
      return h;
    },
    outOfChina: function (t, s) {
      return s < 72.004 || s > 137.8347 || t < 0.8293 || t > 55.8271;
    },
    transformLat: function (t, s) {
      var i =
        2 * t -
        100 +
        3 * s +
        0.2 * s * s +
        0.1 * t * s +
        0.2 * Math.sqrt(Math.abs(t));
      return (
        (i +=
          (2 *
            (20 * Math.sin(6 * t * this.PI) + 20 * Math.sin(2 * t * this.PI))) /
          3),
        (i +=
          (2 *
            (20 * Math.sin(s * this.PI) + 40 * Math.sin((s / 3) * this.PI))) /
          3),
        (i +=
          (2 *
            (160 * Math.sin((s / 12) * this.PI) +
              320 * Math.sin((s * this.PI) / 30))) /
          3)
      );
    },
    transformLon: function (t, s) {
      var i =
        300 +
        t +
        2 * s +
        0.1 * t * t +
        0.1 * t * s +
        0.1 * Math.sqrt(Math.abs(t));
      return (
        (i +=
          (2 *
            (20 * Math.sin(6 * t * this.PI) + 20 * Math.sin(2 * t * this.PI))) /
          3),
        (i +=
          (2 *
            (20 * Math.sin(t * this.PI) + 40 * Math.sin((t / 3) * this.PI))) /
          3),
        (i +=
          (2 *
            (150 * Math.sin((t / 12) * this.PI) +
              300 * Math.sin((t / 30) * this.PI))) /
          3)
      );
    },
    gpsToLl3857: function (t) {
      return (0, s.default)("EPSG:4326", "EPSG:3857", t);
    },
  };
exports.default = i;
